package com.example.mapper;


import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.entity.auth.SysMenu;
import com.example.entity.auth.SysRole;
import com.example.entity.dto.User.UserLoginDto;
import com.example.entity.vo.CMSMFVo;
import org.apache.ibatis.annotations.Select;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Set;

public interface UserMapper {

    @Select("SELECT MA068 FROM CMSMA")
    Integer getma068();

    @Select("SELECT MF001,MF002,MF003,MF004,MF005,MF006 FROM CMSMF")
    List<CMSMFVo> getcmsmf();

    @Select("SELECT COUNT(*) FROM taskinituser a LEFT JOIN taskInit b ON  a.form_key=b.form_key AND a.task_id = b.task_id \n" +
            " WHERE a.form_key = 'coptc' AND a.task_id = 'xiaoshouzuzhang' AND a.logotype = 0 AND (a.candidate_user = #{userId}   OR b.assignee = #{userId}  ) OR a.form_key = 'coptc2' AND a.task_id = 'xiaoshouzuzhang' AND a.logotype = 0 \n" +
            " AND (a.candidate_user = #{userId}  OR b.assignee = #{userId} )")
    Integer querySg(String userId);

    @DS("DSCSYS")
    @Transactional(propagation = Propagation.REQUIRES_NEW)
    String getPwdById(String userId);

    @DS("DSCSYS")
    Integer userLogin(UserLoginDto userLoginDto);

//    @DS("mes")
    List<SysRole> getRole(String userId);

//    @DS("mes")
    List<SysMenu> getPermission(String userId);

//    @DS("mes")
    Integer getUserIdByUsername(String username);

//    @DS("mes")
    void insertSysUser(String username);

    @DS("DSCSYS")
    void updatePwd(String userId, String password);

    @DS("DSCSYS")
    @Select("select MA002 from DSCMA WHERE MA001 = #{userId}")
    @Transactional(propagation = Propagation.REQUIRES_NEW)
    String query(String userId);
}
